
CC = g++
APP = vss

CFLAGS = -c $<  -I./include -Wall -I./config
CFLAGS += -DFAKE_DATA
CPPFLAGS += -I./include
CPPFLAGS += -I./config

SRCS_COMMON = NetworkFw.cpp HttpParser.cpp Logger.cpp

ifeq ($(APP), vss)
SRCS = SimVss.cpp $(SRCS_COMMON)
else
SRCS = CdnNode.cpp FileManager.cpp $(SRCS_COMMON)
endif

OBJS = $(SRCS:%.cpp=obj/%.o)
DEPENDS = $(OBJS:.o=.d)
TARGET := bin/$(APP)

vpath %.cpp src
vpath %.h include config
vpath %.d obj 
vpath %.o obj 

all: $(TARGET)

include $(DEPENDS)

obj/%.d: %.cpp
	@-[ -d obj ] || mkdir obj
	@set -e;\
	    rm -f $@;\
	    $(CC) -MM $(CPPFLAGS) -Iinclude $< > $@.$$$$;\
	    sed 's,\($*\)\.o[ :]*,obj/\1.o $@ : ,g' < $@.$$$$ > $@;\
	    rm -f $@.$$$$


$(TARGET): $(OBJS) lib/libtinyxml.a -lpthread
	$(CC) -o $@ $^


obj/%.o: %.cpp 
	@[ -d obj ] || mkdir obj
	$(CC) -o $@ $(CFLAGS)

clean:
	-rm -f obj/* 
	-rm -f log/*
	-rm -f $(TARGET)

tag:
	ctags -R --c++-kinds=+p --fields=+iaS --extra=+q
	cscope -Rbq

test:
	@echo $(APP)
	@echo $(OBJS)
	@echo $(DEPENDS)
	@echo $(CPPFLAGS)


